app.controller("patrolCtr",function($scope,httpService,FileUploader,$timeout,toaster){$scope.deviceList=[],$scope.page=1,$scope.busy=!1,$scope.limit=20,$scope.edit=function(Id){
// 还原表单以及表单值
$scope.deviceForm.$setPristine(),Id?($scope.deviceId=Id,$scope.editModalTitle="修改设施",$scope.getDeviceDetail(Id)):($scope.deviceId=null,$scope.deviceModel={Name:"",Code:"",RFID:"",Lat:0,Lng:0,Addr:"",DeviceTypeId:null,Contact:"",Phone:"",StartAt:"",EndAt:"",Spec:"",UseDept:"",Ext:"",Imgs:[]},$scope.editModalTitle="新增设施"),$("#editModal").modal("show")},
//设施表单提交
$scope.deviceFormSubmit=function(){
// $scope.deviceForm.$invalid = true;
var path="/device",type="POST";$scope.deviceId&&(path="/device/"+$scope.deviceId,type="PUT"),httpService.request(type,path,$scope.deviceModel,function(result){
// $scope.deviceForm.$invalid = false;
toaster.pop("success","提示",result.message),$("#editModal").modal("hide"),$scope.getDeviceList()})},
//删除设施弹框处理
$scope.del=function(item){$scope.delModel=angular.copy(item),$("#delModal").modal("show")},
//确认删除设施
$scope.delConfirm=function(){$("#delModal").modal("hide");var path="/device/"+$scope.delModel.Id;httpService.request("DELETE",path,null,function(result){toaster.pop("success","提示",result.message),$scope.getDeviceList()})},$scope.thumbs=function(){$(".thumbs a").touchTouch()},
// 日期组件
$scope.openStart=function($event){$event.preventDefault(),$event.stopPropagation(),$scope.openStarted=!0},$scope.openEnd=function($event){$event.preventDefault(),$event.stopPropagation(),$scope.openEnded=!0},$scope.randomSize=function(){var body=angular.element("body").height(),navbar=angular.element(".navbar-inner").height(),pagebreadcrumbs=angular.element(".page-breadcrumbs").height()+18+15,mainheader=angular.element(".main-header").height()+15,slwrap=angular.element(".sl-wrap").height(),autoheight=body-(navbar+pagebreadcrumbs+mainheader+slwrap-120);angular.element(".divlist").height(autoheight),console.log(autoheight)},
//获取设施列表
$scope.getDeviceList=function(){if($scope.busy)return!1;var path="/device?page="+$scope.page+"&limit="+$scope.limit;// '/device?page=1&limit=40';
$scope.busy=!0,httpService.request("GET",path,null,function(result){
//$scope.deviceList = result.data;
angular.forEach(result.data,function(data,i){$scope.deviceList.push(data)}),result.data.length>=$scope.limit&&($scope.busy=!1,$scope.page+=1),$scope.randomSize()})},
//获取设施详情
$scope.getDeviceDetail=function(Id){var path="/device/"+Id;httpService.request("GET",path,null,function(result){$scope.deviceModel=result.data})},
//获取设施类型
$scope.getDeviceType=function(){var path="/devicetype";httpService.request("GET",path,null,function(result){$scope.deviceTypeList=result.data})};var uploader;uploader=$scope.uploader=new FileUploader({url:"/file/upload2/report",withCredentials:1}),
//点击按钮上传图片
$scope.uploadSubmit=function(){$("#upload_input").click()},
//文件框改变开始上传文件
$scope.uploadFile=function(){
//每次上传前删除之前上传的内容
uploader.clearQueue();var timer=$timeout(function(){uploader.uploadAll(),$timeout.cancel(timer)})},
//上传之前
uploader.onBeforeUploadItem=function(item){$scope.fileName=item.file.name},
// 上传成功
uploader.onSuccessItem=function(item,response,status,headers){},/**
     * 设施定位操作
     * @param id 传入设施id
     *
     */
$scope.location=function(id){},
//地图高度
$scope.mapheight=400,$scope.mapIntialed=function($scope){
//初始化地图操作对象(基于此对象操作地图元素)
var mapobj=$scope.$$childHead.mapinstance;mapobj.addDynamicMap($rootScope.arcgisConfig.baseMap),mapobj.addFeatureLayer("设备点",{maxScale:0,minScale:0,showInfoTemplate:!1})},$scope.searchList=[{typeName:"类型1",typeList:[{id:1,name:"test1"},{id:2,name:"test2"},{id:3,name:"test3"},{id:4,name:"test4"}]},{typeName:"类型2",typeList:[{id:5,name:"test5"},{id:6,name:"test6"},{id:7,name:"test7"}]}],
//获取设施列表
$scope.getDeviceList(),
//获取设施分类
$scope.getDeviceType(),$(".date").datetimepicker({language:"zh-CN",format:"yyyy-mm-dd hh:ii:ss",pickerPosition:"bottom-left"}).on("changeDate",function(ev){$(this).datetimepicker("hide")})});